package com.yoomiito.app.ui.anyview.order

import android.content.Context
import android.view.View
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.TextView

import com.yoomiito.app.R
import com.yoomiito.app.interf.BaseOrderGoodsView
import com.yoomiito.app.model.bean.AppInterfaceInfo
import com.yoomiito.app.model.bean.GoodsDetail
import com.yoomiito.app.utils.AllUtils
import com.yoomiito.app.utils.ImageLoader
import com.yoomiito.app.utils.SpannableUtils
import com.yoomiito.app.widget.NumControlView
import kotlinx.android.synthetic.main.item_order_goods.view.*
import kotlinx.android.synthetic.main.item_order_num.view.*

/**
 * 确认订单------商品信息 数量 优米抵扣
 */
class StarStoreGoodsOrderView(context: Context, detail: GoodsDetail,  appInterfaceInfo: AppInterfaceInfo) : BaseOrderGoodsView(context, detail,appInterfaceInfo) {

    private var mGoodsSize = 1

    override fun getView(): Int {
        return R.layout.view_youpin_order_goods
    }

    override fun initView() {
        goods_size_control_view.visibility = View.GONE
        val frameLayout = findViewById<FrameLayout>(R.id.frameLayout)
        frameLayout.visibility = View.GONE

        ImageLoader.getInstance().into(mContext, mGoodsDetail.pict_url, item_order_goods_iv)
        item_order_goods_title.text = mGoodsDetail.title
        item_order_goods_price.text = "¥" + mGoodsDetail.salePrice

        changeMoney()
    }

    private fun changeMoney() {
        mGoodsTotalPrice = AllUtils.priceMul_2(mGoodsDetail.salePrice, mGoodsSize)
        val s = "合计: ¥$mGoodsTotalPrice"
        val p = s.indexOf("¥")
        spanText = SpannableUtils.getSizeAndPriceText(s, R.color.color_FF035B, p, s.length, p, p + 1)
        if (mOnShowInfoListener != null) {
            mOnShowInfoListener.onShow(spanText, mGoodsSize, 0)
        }
    }
}
